<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        window.onload = function () {
            document.getElementById('btn1').onclick = function () {
                console.log(document.getElementById('input1').value);
                console.log(document.getElementById('div1').innerHTML);
                console.log(document.getElementById('div2').innerText);
            }

            document.getElementById('btn2').onclick = function () {
                document.getElementById('input1').value = 'admin';
                document.getElementById('div1').innerHTML = '<div style="background-color: red;width: 200px;height: 200px">这是添加进来的DIV</div>';
                document.getElementById('div2').innerText = '<div style="background-color: red;width: 200px;height: 200px">这是添加进来的DIV</div>';
            }
        }
    </script>
</head>
<body>
<div id="div1">
    div1
    <div>div1需要被取值的内容</div>
    div1
</div>
<div id="div2">
    div2
    <div>div2需要被取值的内容</div>
    div2
</div>

<input id="input1" type="text"/><br>
<input id="input2" type="text"/><br>
<input id="input3" type="text"/><br>
<input id="input4" type="text"/><br>

<button type="button" id="btn1">取值按钮</button>
<button type="button" id="btn2">赋值按钮</button>
</body>
</html>